// 获取今天的时间戳
function getDayTime() {
    const date = new Date();
    date.setHours(0);
    date.setMinutes(0);
    date.setSeconds(0);
    date.setMilliseconds(0);
    return date.getTime();
}

// 获取前一天的日期
function prevDay(timestemp = (new Date()).getTime()) {
    const date = new Date(timestemp);
    const year = date.getFullYear();
    const month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
    const day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
    return year + month + day
}
// 转换为带汉字的月日
function formatDay(date) {
    let month = date.substr(4, 2);
    let day = date.substr(6, 2);
    if (month.substr(0, 1) === "0") month = month.substr(1, 1);
    if (day.substr(0, 1) === "0") day = day.substr(1, 1);
    return `${month}月${day}日`
}
export default {
    getDayTime,
    prevDay,
    formatDay
}